//
//  HeadReusableView.m
//  ArtDog
//
//  Created by dllo on 16/9/1.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "HeadReusableView.h"
#import "Masonry.h"
#import "UIColor+Common.h"

@interface HeadReusableView ()

@property (nonatomic, strong) UIImageView *leftImageView;

@property (nonatomic, strong) UIImageView *rightImageView;

@end

@implementation HeadReusableView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupSubviews];
        [self layoutAllViews];
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (void)setupSubviews
{
    _leftImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"right"]];
    [self addSubview:_leftImageView];
    
    _titleLabel = [[UILabel alloc]init];
    [self addSubview:_titleLabel];
    _titleLabel.font = [UIFont systemFontOfSize:17];
    _titleLabel.textColor = [UIColor blackColor];
    
    _moreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self addSubview:_moreBtn];
    _moreBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    [_moreBtn setTitleColor:[UIColor colorFromHexRGB:@"505050"] forState:UIControlStateNormal];
    [_moreBtn setTitle:@"MORE" forState:UIControlStateNormal];
    [_moreBtn addTarget:self action:@selector(moreAction:) forControlEvents:UIControlEventTouchUpInside];
    
    _rightImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"icon_next"]];
    [self addSubview:_rightImageView];
    
}

- (void)layoutAllViews
{
    [_leftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(20);
        make.centerY.equalTo(self);
        make.width.height.mas_equalTo(15);
    }];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.left.equalTo(_leftImageView.mas_right).offset(10);
    }];
    [_moreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(_rightImageView.mas_left).offset(-5);
        make.centerY.equalTo(self);
    }];[_rightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-20);
        make.centerY.equalTo(self);
        make.width.height.mas_equalTo(10);
    }];
}

- (void)moreAction:(UIButton *)button
{
    
}

@end
